/* let one1 = document.getElementById("one");
one1.style.color = 'pink';
one1.style.fontSize = "2em"
let all1 = document.getElementsByTagName("p");
document.write(all1.length);
let cl = document.getElementsByClassName("two");
document.write(cl.length)
let na = document.getElementsByName("three");
document.write(na.length)


let fore = document.getElementById('fore');
console.log(fore.innerText)
fore.innerHTML = 'Hello 111';

/* document.getElementsByTagName('p')[4].title = 'aaaa';//鼠标悬停显示信息
let userName = document.getElementsByTagName('input')[0];
userName.value = 'zhangsan';
userName.disabled = true;//不可修改 */


/*document.getElementsByTagName('p')[5].setAttribute('title','aaaa');
let userName = document.getElementsByTagName('input')[0];
userName.setAttribute('value','zhangsan');
userName.setAttribute('disabled',true);
//移除属性disabled
userName.removeAttribute("disabled");
console.log(userName.getAttribute('value')) */


function onClick() {
    if (inputsAreEmpty()) {
        label.textContent = 'Error: 有一个或者两个文本框值为空';
        return;
    }
    updateLabel();
}
function inputsAreEmpty() {
    if (getNumber1() === '' || getNumber2() === '') {
        return true;
    } else {
        return false;
    }
}
function updateLabel() {
    let addend1 = getNumber1();
    let addend2 = getNumber2();
    let sum = (+addend1) + (+addend2);
    label.textContent = (+addend1) + ' + ' + (+addend2) + ' = ' + sum;
}
function getNumber1() {
    return inputs[0].value;
}
function getNumber2() {
    return inputs[1].value;
}
let inputs = document.querySelectorAll('input');
let label = document.querySelector('p');
let button = document.querySelector('button');
button.addEventListener('click', onClick);